home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d13
/
pcrsep89.arc
/
SEEP.BAS
< prev
next >
Wrap
BASIC Source File
|
1990-03-21
|
1KB
|
50 lines
' A Quick Basic program which simulates water seeping through rocks and soil
' Save as: SEEP.BAS
' Compile: BC SEEP;
' LINK SEEP CA;
DEFINT A-Z
' $INCLUDE: 'CA.BI'
COMMON SHARED CellRow, p!
CONST Dry = 0
CONST Wet = 1
CLS
DO
INPUT "Enter probability (0 to 1) ==> ", p!
LOOP WHILE p! <= 0 OR p! >= 1
x% = CAINIT(5, VARPTR(CaArray(0))) 'Use 200 x 320 CGA graphics
RANDOMIZE TIMER
FOR i = 1 TO 320
CALL CASET(1, i, Wet) 'Set whole top row wet
NEXT i
CASHOW 'Show starting screen
CellRow = 2 'Keep track of rows
DO WHILE INKEY$ = ""
CAGEN
CellRow = CellRow + 1
LOOP
CARESET
END
FUNCTION CaCell% 'Do the work here
IF CaArray(SelfRow) <> CellRow THEN 'If this isn't the correct row
result = CaArray(Self) ' then don't change
ELSE
result = Dry 'Assume we're dry
FOR i = NorthWest TO NorthEast STEP 2 'Look both ways --
IF CaArray(i) = Wet THEN 'If either is wet, then
IF RND < p! THEN ' we have a chance to be wet
result = Wet
END IF
END IF
NEXT i
END IF
CaCell% = result
END FUNCTION